home *** CD-ROM | disk | FTP | other *** search
/ Atari Mega Archive 1 / Atari Mega Archive - Volume 1.iso / language / dl_exsrc.zoo / catch.c < prev    next >
C/C++ Source or Header  |  1994-07-03  |  348b  |  24 lines

  1. #include <setjmp.h>
  2. #include "extras.h"
  3.  
  4. static int hold_rv;
  5.  
  6. int catch(context, func)
  7.   jmp_buf context;
  8.   int (*func) __PROTO((void));
  9. {
  10.   if (setjmp(context) == 0) {
  11.     return (*func)();
  12.   } else {
  13.     return hold_rv;
  14.   }
  15. }
  16.  
  17. void throw(context, rv)
  18.   jmp_buf context;
  19.   int rv;
  20. {
  21.   hold_rv = rv;
  22.   longjmp(context, 1);
  23. }
  24.